<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .abc {
				color: red;
			}
        </style>
    </head>
    <body>
        <div id="box">
			<ul v-if="lists.length>0">
				<li v-for="(list,index) in lists">
				    {{list.value}}
					<button type="button" @click="del(index)">删除</button>      <!--点击获取索引-->
				</li>
			</ul>
			<input type="text" ref="input1" v-on:keyup.enter="key" />
		</div>


		<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
		<script src="./js/vue.js"></script>
		<script>
			var lists = [];
			let vm = new Vue({
				el: '#box',
				data: {
					lists: lists
				},
				methods: {
					key: function() {
						lists.push({
							value: this.$refs.input1.value
						})
					},
					del: function(index) {
						console.log(index)
						lists.splice(index,1)     //根据索引删除
					}
					
				}
			})
		</script>
    </body>
</html>